package com.bdqn.demo02.logger;

/**
 * MemberATM
 *
 * @author LILIBO
 * @since 2022-09-27
 */
public class MemberATM implements ATM {

    /**
     * 转账
     *
     * @param accountFrom 转出账户
     * @param accountTo 转入账户
     * @param money 转多少钱
     * @return 是否成功
     */
    @Override
    public boolean transfer(Account accountFrom, Account accountTo, double money) {
        System.out.println("转出账户" + accountFrom.toString());
        System.out.println("转入账户" + accountTo.toString());
        if (accountFrom.getMoney() < money) {
            System.out.println("余额不足，转账失败");
            return false;
        }
        // 出账
        accountFrom.setMoney(accountFrom.getMoney() - money);
        // 入账
        accountTo.setMoney(accountTo.getMoney() + money);
        System.out.println("。。。。。。。。 转账完成");
        System.out.println("转出账户" + accountFrom.toString());
        System.out.println("转入账户" + accountTo.toString());
        return true;
    }

}
